package com.timecomplexity;

/**
 * Created by Administrator on 2020-07-16.
 * 0,1,1,3,5,8,13,21
 */
public class FibTest {
    public static int fib1(int n){
        if (n<=1){
            return n;
        }
        return fib1(n-2)+fib1(n-1);

    }
    public static int fib2(int n){
        int first=0;
        int second=1;
        while (n-->1){
            second=first+second;
            first=second-first;
        }
        return second;


    }

    public static void main(String[] args) {
        System.out.println(fib2(6));
    }
}
